package com.wiseman.writing;


import com.umeng.analytics.MobclickAgent;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class GradeActivity extends Activity implements OnClickListener, ConstValue{
	
	int btIDs[] = {
			R.id.btKinderGarden,
			R.id.btGrade1A, R.id.btGrade1B,
			R.id.btGrade2A, R.id.btGrade2B,
			R.id.btGrade3A, R.id.btGrade3B,
			R.id.btGrade4A, R.id.btGrade4B,
			R.id.btGrade5A, R.id.btGrade5B,
			R.id.btGrade6A, R.id.btGrade6B,			
		};
	
	String eventType[] = {
			"wc_class_preschool",
			"wc_class_one",
			"wc_class_two",
			"wc_class_three",
			"wc_class_four",
			"wc_class_five",
			"wc_class_six",
	};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.grade_activity);
				
		Button bt = null;
		
		for(int i= 0; i < btIDs.length; i++){		
			bt = (Button) findViewById(btIDs[i]);
			bt.setOnClickListener(this);
			bt.setTag(i);
		}		
	}

	@Override
	public void onClick(View v) {
		
		int id = (Integer) v.getTag();
		
		String event = id == 0?eventType[0]:eventType[(id-1)/2+1];
	
		MobclickAgent.onEvent(this, event); 
		
		Intent intent = new Intent();
		intent.setClass(this, StudyActivity.class);
		intent.putExtra(GRADE_ID, id);
		
		startActivity(intent);
	}

}
